﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefProductBOM" :model="stateProductBOM.vmModel" label-width="100px">
    <div style="margin-bottom:10px;">{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_FactoryCode_FormItem" prop="LinkedVM.FactoryCode" :label="$t('message.autotrans._Model_ProductBOM_factoryCode')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.FactoryCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Assemblyline_FormItem" prop="LinkedVM.Assemblyline" :label="$t('message.autotrans._Model_ProductBOM_assemblyline')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.Assemblyline" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OperationCode_FormItem" prop="LinkedVM.OperationCode" :label="$t('message.autotrans._Model_ProductBOM_operationCode')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.OperationCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OrderCode_FormItem" prop="LinkedVM.OrderCode" :label="$t('message.autotrans._Model_ProductBOM_orderCode')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.OrderCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ScheduleNumber_FormItem" prop="LinkedVM.ScheduleNumber" :label="$t('message.autotrans._Model_ProductBOM_scheduleNumber')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.ScheduleNumber" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AddTime_FormItem" prop="LinkedVM.AddTime" :label="$t('message.autotrans._Model_ProductBOM_addTime')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.AddTime" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyConsumption_FormItem" prop="LinkedVM.AssemblyConsumption" :label="$t('message.autotrans._Model_ProductBOM_assemblyConsumption')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.AssemblyConsumption" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyMaterialCode_FormItem" prop="LinkedVM.AssemblyMaterialCode" :label="$t('message.autotrans._Model_ProductBOM_assemblyMaterialCode')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductBOM_assemblyMaterialCode')}), trigger: 'blur' }]" >
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.AssemblyMaterialCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyMaterialId_FormItem" prop="LinkedVM.AssemblyMaterialId" :label="$t('message.autotrans._Model_ProductBOM_assemblyMaterialId')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductBOM_assemblyMaterialId')}), trigger: 'blur' }]" >
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.AssemblyMaterialId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyMaterialName_FormItem" prop="LinkedVM.AssemblyMaterialName" :label="$t('message.autotrans._Model_ProductBOM_assemblyMaterialName')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.AssemblyMaterialName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyMaterialRegex_FormItem" prop="LinkedVM.AssemblyMaterialRegex" :label="$t('message.autotrans._Model_ProductBOM_assemblyMaterialRegex')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.AssemblyMaterialRegex" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyMaterialVersion_FormItem" prop="LinkedVM.AssemblyMaterialVersion" :label="$t('message.autotrans._Model_ProductBOM_assemblyMaterialVersion')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.AssemblyMaterialVersion" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AssemblyUnitCode_FormItem" prop="LinkedVM.AssemblyUnitCode" :label="$t('message.autotrans._Model_ProductBOM_assemblyUnitCode')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.AssemblyUnitCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AutoMaterialDeduction_FormItem" prop="LinkedVM.AutoMaterialDeduction" :label="$t('message.autotrans._Model_ProductBOM_autoMaterialDeduction')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.AutoMaterialDeduction" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_EditTime_FormItem" prop="LinkedVM.EditTime" :label="$t('message.autotrans._Model_ProductBOM_editTime')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.EditTime" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Field1_FormItem" prop="LinkedVM.Field1" :label="$t('message.autotrans._Model_ProductBOM_field1')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.Field1" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Field2_FormItem" prop="LinkedVM.Field2" :label="$t('message.autotrans._Model_ProductBOM_field2')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.Field2" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Field3_FormItem" prop="LinkedVM.Field3" :label="$t('message.autotrans._Model_ProductBOM_field3')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.Field3" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Field4_FormItem" prop="LinkedVM.Field4" :label="$t('message.autotrans._Model_ProductBOM_field4')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.Field4" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Field5_FormItem" prop="LinkedVM.Field5" :label="$t('message.autotrans._Model_ProductBOM_field5')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.Field5" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_IsDelete_FormItem" prop="LinkedVM.IsDelete" :label="$t('message.autotrans._Model_ProductBOM_isDelete')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.IsDelete" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_MaterialCode_FormItem" prop="LinkedVM.MaterialCode" :label="$t('message.autotrans._Model_ProductBOM_materialCode')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.MaterialCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_MaterialId_FormItem" prop="LinkedVM.MaterialId" :label="$t('message.autotrans._Model_ProductBOM_materialId')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.MaterialId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_MaterialName_FormItem" prop="LinkedVM.MaterialName" :label="$t('message.autotrans._Model_ProductBOM_materialName')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.MaterialName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_MaterialRegex_FormItem" prop="LinkedVM.MaterialRegex" :label="$t('message.autotrans._Model_ProductBOM_materialRegex')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.MaterialRegex" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_MaterialSort_FormItem" prop="LinkedVM.MaterialSort" :label="$t('message.autotrans._Model_ProductBOM_materialSort')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.MaterialSort" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_MaterialVersion_FormItem" prop="LinkedVM.MaterialVersion" :label="$t('message.autotrans._Model_ProductBOM_materialVersion')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.MaterialVersion" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OrderId_FormItem" prop="LinkedVM.OrderId" :label="$t('message.autotrans._Model_ProductBOM_orderId')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.OrderId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OrderQty_FormItem" prop="LinkedVM.OrderQty" :label="$t('message.autotrans._Model_ProductBOM_orderQty')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.OrderQty" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ProductBomId_FormItem" prop="LinkedVM.ProductBomId" :label="$t('message.autotrans._Model_ProductBOM_productBomId')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.ProductBomId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ReplaceMaterialList_FormItem" prop="LinkedVM.ReplaceMaterialList" :label="$t('message.autotrans._Model_ProductBOM_replaceMaterialList')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.ReplaceMaterialList" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Replaces_FormItem" prop="LinkedVM.Replaces" :label="$t('message.autotrans._Model_ProductBOM_replaces')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.Replaces" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Retroactive_FormItem" prop="LinkedVM.Retroactive" :label="$t('message.autotrans._Model_ProductBOM_retroactive')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.Retroactive" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_RouteBomCode_FormItem" prop="LinkedVM.RouteBomCode" :label="$t('message.autotrans._Model_ProductBOM_routeBomCode')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.RouteBomCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_RouteBomName_FormItem" prop="LinkedVM.RouteBomName" :label="$t('message.autotrans._Model_ProductBOM_routeBomName')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.RouteBomName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_RouteNumber_FormItem" prop="LinkedVM.RouteNumber" :label="$t('message.autotrans._Model_ProductBOM_routeNumber')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.RouteNumber" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ShipRegularCheck_FormItem" prop="LinkedVM.ShipRegularCheck" :label="$t('message.autotrans._Model_ProductBOM_shipRegularCheck')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.ShipRegularCheck" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ShopOrderOperationMaterialId_FormItem" prop="LinkedVM.ShopOrderOperationMaterialId" :label="$t('message.autotrans._Model_ProductBOM_shopOrderOperationMaterialId')">
          <el-input v-model="stateProductBOM.vmModel.LinkedVM.ShopOrderOperationMaterialId" clearable></el-input>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitProductBOM"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseProductBOM"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageBaseInformationProductBOMBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { productbomApi } from '/@/api/baseinformation/productbom';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefProductBOM = ref();
const stateProductBOM = reactive({
    vmModel: {
	  LinkedVM:{
        FactoryCode: '',
        Assemblyline: '',
        OperationCode: '',
        OrderCode: '',
        ScheduleNumber: '',
        AddTime: '',
        AssemblyConsumption: '',
        AssemblyMaterialCode: '',
        AssemblyMaterialId: '',
        AssemblyMaterialName: '',
        AssemblyMaterialRegex: '',
        AssemblyMaterialVersion: '',
        AssemblyUnitCode: '',
        EditTime: '',
        Field1: '',
        Field2: '',
        Field3: '',
        Field4: '',
        Field5: '',
        IsDelete: '',
        MaterialCode: '',
        MaterialId: '',
        MaterialName: '',
        MaterialRegex: '',
        MaterialSort: '',
        MaterialVersion: '',
        OrderId: '',
        OrderQty: '',
        ProductBomId: '',
        ReplaceMaterialList: '',
        Retroactive: '',
        RouteBomCode: '',
        RouteBomName: '',
        RouteNumber: '',
        ShipRegularCheck: '',
        ShopOrderOperationMaterialId: '',
      },
      Ids:[],
      
	},
    
});

// 取消
const onCloseProductBOM = () => {
    closeDialog();
};

// 提交
const onSubmitProductBOM = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefProductBOM.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            productbomApi().batchedit(stateProductBOM.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
	})
};


// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateProductBOM.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateProductBOM.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

